﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LanDBom.Models.Procure
{
    public class Find_Libary
    {
        LDbaseEntities db = new LDbaseEntities();
        public List<libray> Edites(string lB_bai, string lB_fne, string sT_fne)
        {
            List<Steelmaking> steelmakings = db.Steelmaking.ToList();   
            List<libray> librays = db.libray.ToList();
            if (lB_bai != "")
            {
                librays = librays.Where(a => a.LB_bai.Contains(lB_bai)).ToList();
            }
            if (lB_fne != "")
            {
                librays = librays.Where(a => a.LB_fne.Contains(lB_fne)).ToList();
            }
            if (sT_fne != "")
            {
                librays = librays.Where(s=>s.ST_ID== int.Parse(sT_fne)).ToList();
            }
            return librays;
        }
        public List<Providers> EditeGS(string lB_bai, string lB_fne, string sT_fne)
        {
            List<Providers> librays = db.Providers.Where(x=>x.PR_bei=="准入"||x.PR_bei=="临时").ToList();
            foreach(Providers providers in librays)
            {
                if (providers.PR_name == null)
                {
                    providers.PR_name = "";
                }
                if (providers.PR_di == null)
                {
                    providers.PR_di = "";
                }
                if (providers.PR_lian == null)
                {
                    providers.PR_lian = "";
                }
            }
            if (lB_bai != "")
            {
                librays = librays.Where(a => a.PR_name.Contains(lB_bai)).ToList();
            }
            if (lB_fne != "")
            {
                librays = librays.Where(a => a.PR_di.Contains(lB_fne)).ToList();
            }
            if (sT_fne != "")
            {
                librays = librays.Where(a => a.PR_lian.Contains(sT_fne)).ToList();
            }
            return librays;
        }
    }
}